package com.dataart.productshop.dao.impl;

import com.dataart.productshop.dao.KathedraDao;
import com.dataart.productshop.model.boiko.informationsystem.Kathedra;
import com.dataart.productshop.model.boiko.informationsystem.Subject;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class KathedraDaoImpl extends  BaseDaoImpl<Kathedra> implements KathedraDao{
    public KathedraDaoImpl() {
        super(Kathedra.class);
    }


    public void removeByName(String name){
        List<Kathedra> selected = getByName(name);
        if(selected != null){
            for (Kathedra kathedra : selected) {
                delete(kathedra.getId());
            }
        }
    }

    public List<Kathedra> getByName(String name){
        return createCriteria(Kathedra.class)
                .add(Restrictions.eq("name", name))
                .list();
    }
}
